<template>
  <web-view
    :src="webUrl"
    :webview-styles="webviewStyles"
    @message="handleMessage"
    @error="error"
  ></web-view>
</template>

<script>
export default {
  data() {
    return {
      webUrl: 'https://ya30wxmp.hbwlife.com/mySwimTicket',
      webviewStyles: {
        progress: {
          color: '#FF3333',
        },
      },
    }
  },
  onLoad() {
    let data = {
      token: 'fqwafsa',
      userid: '1213',
    }
    this.webUrl =
      this.webUrl + `?data=${encodeURIComponent(JSON.stringify(data))}`
   // console.log(this.webUrl)
  },
  method: {
    handleMessage(data) {
      console.log('小程序接收到的消息：', data.detail.data)
      uni.$emit('login', {
        userName: 'hhh',
      })
    },
  },
}
</script>
